<?php

namespace app\api\controller;

use app\BaseController;
use think\facade\Db;
use app\api\logic\ApiAssetLogic;
use Throwable;

class ApiAsset extends BaseController
{
    /**
     * 模型
     * @var object
     * @phpstan-var ApiAdvaccountModel
     */

    public function initialize(): void
    {
        parent::initialize();
    }

    /**
     * 获取主题
     * @throws Throwable
     */
    public function ThemesList()
    {
        $params     = $this->request->get();
        $ApiAssetLogic = new ApiAssetLogic();
        return $ApiAssetLogic->ThemesList($params);
    }

    /**
     * 获取资产
     * @throws Throwable
     */
    public function ThemesAssets()
    {
        $params     = $this->request->get();
        $ApiAssetLogic = new ApiAssetLogic();
        return $ApiAssetLogic->ThemesAssets($params);
    }

    /**
     * 把外部链接转成资产
     * @throws Throwable
     */
    public function LinkToAssetConversion()
    {
        $params     = $this->request->get();

        // $params = [
        //     'shop_id' => 17,
        //     'url' => 'https://m.media-amazon.com/images/I/613nlczSqzL._SY88.jpg',
        //     'type' => 'images',
        // ];
        $ApiAssetLogic = new ApiAssetLogic();
        $url = $ApiAssetLogic->LinkToAssetConversion($params);
        halt($url);
        
        return  json(DefaultResponse(200, true, '操作成功', $url));
    }

}
